<?php
class Microblog_WidgetController extends Baogg_Controller_Action_Site
{
	/**
	 * The default action - show the home page
	 */
	/* public function jsonAction ()
	{
		$params=$this->getRequest()->getParams();
		$data=$this->_helper->widget->getJson($params['widget_id'],$params);
		
		echo Zend_Json::encode($data);
		$this->_helper->viewRenderer->setNoRender();
	}
	public function dataAction ()
	{
		$params=$this->getRequest()->getParams();
		$data=$this->_helper->widget->getData($params['widget_id'],$params);
	
		echo Zend_Json::encode($data);
		$this->_helper->viewRenderer->setNoRender();
	} */
	public function __call($method, $args)
	{
		if ('Action' == substr($method, -6)) {
			// If the action method was not found, render the error
			// template
			$params=$this->getRequest()->getParams();
			$func=substr($method, 0,-6);
			$data=$this->_helper->widget->$func($params['widget_id'],$params);
			echo Zend_Json::encode($data);
			$this->_helper->viewRenderer->setNoRender();
		}else{	
			// all other methods throw an exception
			throw new Exception('Invalid method "'
			. $method
			. '" called',
			500);
		}
	}
}